package com.edu.exam.entity.curriculum.questionbank;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Comment;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 判断题选项实体类
 * 所属模块：B-02 题库管理模块
 * 对应数据库表：true_false_option
 *
 * 根据B-02-03-06判断题管理子模块设计文档实现
 * 管理判断题的选项信息，虽然判断题通常是二元选择（正确/错误），
 * 但该实体提供了灵活的扩展机制以支持未来的功能扩展。
 *
 * @author System
 * @version 1.0.0
 */
@Entity
@Table(name = "true_false_option")
@Comment("判断题选项表")
@EntityListeners(AuditingEntityListener.class)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class JudgmentOption {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    /**
     * 选项唯一标识符
     */
    @NotBlank(message = "选项ID不能为空")
    @Size(max = 50, message = "选项ID长度不能超过50个字符")
    @Column(name = "option_id", nullable = false, length = 50, unique = true)
    private String optionId;

    /**
     * 关联的判断题ID
     */
    @NotBlank(message = "题目ID不能为空")
    @Column(name = "question_id", nullable = false)
    private String questionId;

    /**
     * 选项文本
     */
    @NotBlank(message = "选项文本不能为空")
    @Size(max = 200, message = "选项文本长度不能超过200个字符")
    @Column(name = "option_text", nullable = false, length = 200)
    private String optionText;

    /**
     * 选项代码（T-正确，F-错误，或自定义代码）
     */
    @NotBlank(message = "选项代码不能为空")
    @Size(max = 10, message = "选项代码长度不能超过10个字符")
    @Column(name = "option_code", nullable = false, length = 10)
    private String optionCode;

    /**
     * 是否为正确答案
     */
    @NotNull(message = "正确答案标识不能为空")
    @Column(name = "is_correct", nullable = false)
    private Boolean isCorrect;

    /**
     * 排序顺序
     */
    @NotNull(message = "排序顺序不能为空")
    @Column(name = "sort_order", nullable = false)
    private Integer sortOrder;

    /**
     * 选项类型（STANDARD-标准选项，CUSTOM-自定义选项，EXTENDED-扩展选项）
     */
    @Size(max = 20, message = "选项类型长度不能超过20个字符")
    @Column(name = "option_type", length = 20)
    private String optionType;

    /**
     * 选项解释说明
     */
    @Column(name = "explanation", columnDefinition = "TEXT")
    private String explanation;

    /**
     * 选择反馈信息
     */
    @Column(name = "feedback_text", columnDefinition = "TEXT")
    private String feedbackText;

    /**
     * 是否激活
     */
    @NotNull(message = "激活状态不能为空")
    @Column(name = "is_active", nullable = false)
    private Boolean isActive;

    /**
     * 选项状态（ACTIVE-激活，INACTIVE-非激活，DEPRECATED-已废弃）
     */
    @NotBlank(message = "选项状态不能为空")
    @Size(max = 20, message = "选项状态长度不能超过20个字符")
    @Column(name = "option_status", nullable = false, length = 20)
    private String optionStatus;

    /**
     * 选项样式配置（JSON格式）
     */
    @Column(name = "style_config", columnDefinition = "TEXT")
    private String styleConfig;

    /**
     * 选项图标或图片URL
     */
    @Size(max = 200, message = "图标URL长度不能超过200个字符")
    @Column(name = "icon_url", length = 200)
    private String iconUrl;

    /**
     * 选项颜色配置
     */
    @Size(max = 50, message = "颜色配置长度不能超过50个字符")
    @Column(name = "color_config", length = 50)
    private String colorConfig;

    /**
     * 选项快捷键
     */
    @Size(max = 10, message = "快捷键长度不能超过10个字符")
    @Column(name = "hot_key", length = 10)
    private String hotKey;

    /**
     * 是否允许键盘输入
     */
    @NotNull(message = "键盘输入设置不能为空")
    @Column(name = "allow_keyboard_input", nullable = false)
    private Boolean allowKeyboardInput;

    /**
     * 选项权重（用于随机选择概率）
     */
    @Column(name = "option_weight", precision = 5, scale = 2)
    private Double optionWeight;

    /**
     * 选项分组标识
     */
    @Size(max = 50, message = "分组标识长度不能超过50个字符")
    @Column(name = "group_identifier", length = 50)
    private String groupIdentifier;

    /**
     * 扩展属性（JSON格式）
     */
    @Column(name = "extended_properties", columnDefinition = "TEXT")
    private String extendedProperties;

    /**
     * 版本号
     */
    @NotNull(message = "版本号不能为空")
    @Column(name = "version_number", nullable = false)
    private Integer versionNumber;

    /**
     * 创建者ID
     */
    @Size(max = 50, message = "创建者ID长度不能超过50个字符")
    @Column(name = "created_by", nullable = false, length = 50)
    private String createdBy;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "create_time", nullable = false, updatable = false)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @Column(name = "update_time", nullable = false)
    private LocalDateTime updateTime;

    /**
     * 软删除标识
     */
    @NotNull(message = "软删除标识不能为空")
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted;

    /**
     * 删除时间
     */
    @Column(name = "delete_time")
    private LocalDateTime deleteTime;

    /**
     * 更新人
     */
    @Size(max = 50, message = "更新人长度不能超过50个字符")
    @Column(name = "updated_by", nullable = false, length = 50)
    private String updatedBy;

}